<template>
	<view class="box">
		<!-- 搜索框 -->
		<u-search shape="square" placeholder="搜索" v-model="inputValue" clearabled :show-action="false"
			@search="searchBtn" @clickIcon="searchBtn" bgColor="#fff">
		</u-search>
		<!-- 列表 -->
		<view class="num">入场人数：<text class="c4167C1">{{num}}</text></view>
		<view class="box_list">
			<view class="box_list_item" v-for="(item, index) in list" :key="index" @click="jumpDesc(item)">
				<view class="box_flex flex-c">
					<image :src="item.showFaceUrl || '/static/images/user.png' "></image>
					<view class="right">
						<view class="name">{{item.name}}<text v-if="item.cardName">@{{item.cardName}}</text></view>
						<view class="tel" v-if="item.phone">{{item.phone}}</view>
					</view>
				</view>
				<view class="tip">入场凭证<text class="ml20">{{item.productName}}</text></view>
				<view class="tip">入场时间<text class="ml20">{{item.inTime}}</text></view>
				<view class="tip">在场时间<text class="ml20">{{item.stayTime}}分钟</text></view>
				<view v-if="item.outTime" class="tip">离场时间<text class="ml20">{{item.outTime}}</text></view>
			</view>
		</view>
		<u-loadmore v-if="!is && list.length >= 10" status="nomore" line />
		<view class="no-list" v-if="!list || list.length == 0">
			<image src="@/static/images/default_empty.png"></image>
			<view>暂无数据</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				inputValue: '',
				num: 0,
				page: 0, //页码
				is: true, //控制是否还能切换下一页
				list: [],
			};
		},
		onLoad(options) {
			this.searchBtn()
			this.inPelNum()
		},
		methods: {
			// 点击跳转
			jumpDesc(e) {
				uni.navigateTo({
					url: `/pages/bepresent/details?user=${JSON.stringify(e)}`
				})
			},
			searchBtn() {
				this.is = true
				this.page = 0
				this.list = []
				this.getList()
			},
			inPelNum() {
				this.$app.ajax({
					api: this.$api.inPelNum(),
					data: {
						param: {
							venueId: uni.getStorageSync('GYMID'),
						}
					}
				}).then((res) => {
					if (res.errorCode != '000000') return
					this.num = res.totalCount || 0
				})
			},
			// 列表
			getList() {
				if (!this.is) return
				this.page = this.page + 1
				this.$app.ajax({
					data: {
						pagination: {
							page: this.page,
							rows: 10
						},
						param: {
							venueId: uni.getStorageSync('GYMID'),
							name: this.inputValue
						}
					},
					api: this.$api.inPelList()
				}).then(res => {
					if (res.errorCode != '000000') return
					if (res.recordList.length < 10 || !res.recordList) {
						this.is = false
					}
					let arr = res.recordList
					let arrs = []
					if (arr) {
						arrs = this.list.concat(arr)
					} else {
						arrs = []
					}
					this.list = arrs
				})
			},
			onReachBottom() {
				this.getList();
			},


		}
	};
</script>

<style>
	page {
		padding: 30rpx;
		box-sizing: border-box;
		background: #F7F7F7;
	}
</style>
<style lang="scss" scoped>
	.box_list {
		margin-top: 30rpx;
	}

	.box_list_item {
		padding: 30rpx;
		box-sizing: border-box;
		margin-bottom: 24rpx;
		background: #ffffff;
		border-radius: 8rpx;
	}

	.box_flex image {
		width: 72rpx;
		height: 72rpx;
		margin-right: 30rpx;
		border-radius: 50%;
	}

	.right {
		flex: 1;
	}

	.name {
		font-weight: 500;
		color: #222222;
		font-size: 30rpx;
		line-height: 1.5;
		margin-bottom: 10rpx;
	}

	.name text {
		font-weight: 400;
		color: #4167C1;
		font-size: 22rpx;
		margin-left: 20rpx;
	}

	.tel {
		color: #999999;
		line-height: 1.5;
		font-size: 24rpx;
	}

	.tip {
		color: #333333;
		font-size: 26rpx;
		margin-top: 10rpx;
		line-height: 1.5;
	}

	.num {
		font-weight: 400;
		color: #333333;
		margin-top: 30rpx;
		font-size: 28rpx;
		line-height: 1.5;
	}
</style>